{block:style}
<style>
    .tabs-group .title {
        float: left;
        padding: 10px 0;
        width: 80px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        word-wrap: normal;
    }
    .tabs-group .content {
        list-style: none;
        padding: 0;
        margin: 0 0 0 80px;
        background-color: #ffffff;
    }
    .tabs-group .content > li {
        float: left;
        padding: 5px 12px;
        position: relative;
    }
    .tabs-group .content > li .show-down {
        position: absolute;
        right: 0;
        top: 10px;
        cursor: pointer;
        color: #7b7b7b;
    }
    .tabs-group .content > li > a {
        display: block;
        padding: 4px 5px;
        border: none;
        -webkit-border-radius: 4px;
        -webkit-background-clip: padding-box;
        -moz-border-radius: 4px;
        -moz-background-clip: padding;
        border-radius: 4px;
        background-clip: padding-box;
        color: #828a92;
        -webkit-transition: all 0.3s ease;
        -moz-transition: all 0.3s ease;
        -o-transition: all 0.3s ease;
        transition: all 0.3s ease;
    }
    .tabs-group .content > li.active > a, .tabs-group .content > li:hover > a {
        color: #34D0B6;
    }
    .tabs-group .content > li:hover > .dropdown-menu {
        display: block;
        margin-top: -2px;
    }
    .card-list .card img {
        height: 330px;
        object-fit: cover;
    }
    .card-list .card .card-title {
        width: 100%;
        height: 22px;
        overflow: hidden;
        margin-bottom: 4px;
        font-size: 1.25em;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .card-list .card .card-text {
        width: 100%;
        font-size: 16px;
    }
    .card-list .card:hover {
        box-shadow: 0 0 2px rgba(52, 208, 182,.225), 0 1px 4px rgba(52, 208, 182,.3);
    }
    .user-info {
        position: fixed;
        bottom: 80px;
        right: 30px;
    }
    .user-img {
        margin: 0 auto;
        width: 40px;
        height: 40px;
    }
    .user-img img {
        width: 100%;
        height: 100%;
        border-radius: 100%;
    }
    .user-txt {
        width: 100%;
        margin-top: -10px;
        background-color: #ffffff;
        border-radius: 8px;
        padding: 6px 8px 5px 8px;
        color: #828a92;
        box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    }
    .footer-fa {
        color: #989da2;
        margin-top: 6px;
    }
    .footer-fa span {

        margin-left: 2px;
    }
    /*.nav-pills .nav-link.active, .nav-pills .show>.nav-link {*/
    /*    background-color: #2ebda5;*/
    /*}*/
    .nav-pills .nav-link:not(.active):hover {
        color: #333333;
    }
    .table-bordered td, .table-bordered th {
        text-align: center; vertical-align: middle;
    }
</style>
{/block:style}
<div class="card">
    <div class="card-header p-2">
        <ul class="nav nav-pills">
            {if has_rule('index')}<li class="nav-item"><a class="nav-link" href="{:url('/appcenter/index')}">{:lang("Local")}</a></li>{/if}
            {if has_rule('online')}<li class="nav-item"><a class="nav-link active" href="{:url('/appcenter/online')}">{:lang("Online")}</a></li>{/if}
        </ul>
    </div><!-- /.card-header -->
</div>
<div class="card card-primary card-tabs">
    <div class="card-header">
        <ul class="nav nav-tabs" id="custom-tabs-three-tab" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" data-toggle="pill" href="#template-pane" data-type="template">{:lang("Template")}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" data-toggle="pill" href="#addon-pane" data-type="addon">{:lang("Addon")}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" data-toggle="pill" href="#module-pane" data-type="module">{:lang("Module")}</a>
            </li>
        </ul>
    </div>
    <div class="card-body">
        <div class="tab-content" id="custom-tabs-three-tabContent">
            <div class="tab-pane fade active show" id="template-pane">
                <div class="clearfix">
                    <div class="float-left">
                        <a class="btn btn-secondary" href="javascript:window.location.reload();" aria-label="Refresh" title="{:lang('Refresh')}">
                            <i class="fa fa-sync"></i>
                        </a>
                        &nbsp;
                        {:lang('A total of %s sets of templates',['&nbsp;<span class="template-total">0</span>&nbsp;'])}
                    </div>
                    <div class="float-right">
                        <div class="d-flex ">
                            <input type="text" class="form-control" id="template-keyword" placeholder="{:lang('Search')}" style="width: auto;margin-right: 3px">
                            <button type="button" class="btn btn-primary" onclick="getAddonList('template')"><i class="fa fa-search"></i> {:lang('Search')}</button>
                        </div>
                    </div>
                </div>

                <div class="card mt-3">
                    <div class="card-body">
                        <div class="tabs-group category-panel">
                            <div class="title">{:lang("Classification")}:</div>
                            <ul class="content clearfix"></ul>
                        </div>
                        <div class="tabs-group color_attr">
                            <div class="title">{:lang("Color")}:</div>
                            <ul class="content clearfix">
                            </ul>
                        </div>
                        <div class="tabs-group">
                            <div class="title">{:lang("Price")}:</div>
                            <ul class="content clearfix">
                                <li class="active"><a href="#" data-value="">{:lang("All")}</a></li>
                                <li class=""><a href="#" data-value="price=0">{:lang("Free")}</a></li>
                                <li class=""><a href="#" data-value="price=0,100">100以下</a></li>
                                <li class=""><a href="#" data-value="price=100,200">100-200</a></li>
                                <li class=""><a href="#" data-value="price=200,500">200-500</a></li>
                                <li class=""><a href="#" data-value="price=500">500以上</a></li>
                            </ul>
                        </div>
                        <div class="tabs-group">
                            <div class="title">{:lang("Weigh")}:</div>
                            <ul class="content clearfix">
                                <li class="active"><a href="#" data-value="order=publishtime">{:lang("Latest release")}</a></li>
                                <li class=""><a href="#" data-value="order=views">{:lang("Most clicks")}</a></li>
                                <li class=""><a href="#" data-value="order=downloads">{:lang("Install at most")}</a></li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="card-list">
                    <div class="row template-list"></div>
                    <div class="row justify-content-md-center">
                        <div class="col-md-12">
                            <nav aria-label="Page navigation" class="navigation d-flex justify-content-center">
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane fade" id="addon-pane">
                <div class="clearfix">
                    <div class="float-left">
                        <a class="btn btn-secondary" href="javascript:window.location.reload();" aria-label="Refresh" title="{:lang('Refresh')}">
                            <i class="fa fa-sync"></i>
                        </a> &nbsp;
                        {:lang("%s in total",['&nbsp;<span class="template-total">0</span>&nbsp;'])}
                    </div>
                    <div class="float-right">
                        <div class="d-flex ">
                            <input type="text" class="form-control" id="addon-keyword" placeholder="{:lang('Search')}" style="width: auto;margin-right: 3px">
                            <button type="button" class="btn btn-primary" onclick="getAddonList('addon')"><i class="fa fa-search"></i> {:lang('Search')}</button>
                        </div>
                    </div>
                </div>

                <div class="card mt-3">
                    <div class="card-body">
                        <div class="tabs-group category-panel">
                            <div class="title">{:lang("Classification")}:</div>
                            <ul class="content clearfix"></ul>
                        </div>
                        <div class="tabs-group">
                            <div class="title">{:lang("Price")}:</div>
                            <ul class="content clearfix">
                                <li class="active"><a href="#" data-value="">{:lang("All")}</a></li>
                                <li class=""><a href="#" data-value="price=0">{:lang("Free")}</a></li>
                                <li class=""><a href="#" data-value="price=0,100">100以下</a></li>
                                <li class=""><a href="#" data-value="price=100,200">100-200</a></li>
                                <li class=""><a href="#" data-value="price=200,500">200-500</a></li>
                                <li class=""><a href="#" data-value="price=500">500以上</a></li>
                            </ul>
                        </div>
                        <div class="tabs-group">
                            <div class="title">{:lang("Weigh")}:</div>
                            <ul class="content clearfix">
                                <li class="active"><a href="#" data-value="order=publishtime">{:lang("Latest release")}</a></li>
                                <li class=""><a href="#" data-value="order=views">{:lang("Most clicks")}</a></li>
                                <li class=""><a href="#" data-value="order=downloads">{:lang("Install at most")}</a></li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="card-list">
                    <div class="row template-list"></div>
                    <div class="row justify-content-md-center">
                        <div class="col-md-12">
                            <nav aria-label="Page navigation" class="navigation d-flex justify-content-center">
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane fade" id="module-pane">
                <div class="clearfix">
                    <div class="float-left">
                        <a class="btn btn-secondary" href="javascript:window.location.reload();" aria-label="Refresh" title="{:lang('Refresh')}">
                            <i class="fa fa-sync"></i>
                        </a> &nbsp;
                        {:lang("%s in total",['&nbsp;<span class="template-total">0</span>&nbsp;'])}
                    </div>
                    <div class="float-right">
                        <div class="d-flex ">
                            <input type="text" class="form-control" name="module-keyword" placeholder="{:lang('Search')}" style="width: auto;margin-right: 3px">
                            <button type="button" class="btn btn-primary" onclick="getAddonList('module')"><i class="fa fa-search"></i> {:lang('Search')}</button>
                        </div>
                    </div>
                </div>
                <div class="card mt-3">
                    <div class="card-body">
                        <div class="tabs-group category-panel">
                            <div class="title">{:lang("Classification")}:</div>
                            <ul class="content clearfix"></ul>
                        </div>
                        <div class="tabs-group">
                            <div class="title">{:lang("Price")}:</div>
                            <ul class="content clearfix">
                                <li class="active"><a href="#" data-value="">{:lang("All")}</a></li>
                                <li class=""><a href="#" data-value="price=0">{:lang("Free")}</a></li>
                                <li class=""><a href="#" data-value="price=0,100">100以下</a></li>
                                <li class=""><a href="#" data-value="price=100,200">100-200</a></li>
                                <li class=""><a href="#" data-value="price=200,500">200-500</a></li>
                                <li class=""><a href="#" data-value="price=500">500以上</a></li>
                            </ul>
                        </div>
                        <div class="tabs-group">
                            <div class="title">{:lang("Weigh")}:</div>
                            <ul class="content clearfix">
                                <li class="active"><a href="#" data-value="order=publishtime">{:lang("Latest release")}</a></li>
                                <li class=""><a href="#" data-value="order=views">{:lang("Most clicks")}</a></li>
                                <li class=""><a href="#" data-value="order=downloads">{:lang("Install at most")}</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!--/card mt-2-->
                <div class="card-list">
                    <div class="row template-list"></div>
                    <div class="row justify-content-md-center">
                        <div class="col-md-12">
                            <nav aria-label="Page navigation" class="navigation d-flex justify-content-center"></nav>
                        </div>
                    </div>
                </div>
                <!--/card-list-->
            </div>
        </div>
    </div>
</div>
<!--用户信息-->
<div class="user-info">
    <a href="http://www.hkcms.cn/index/home/user/user/{$ac_user.id}" target="_blank">
        <div class="user-img"><img src="{$ac_user.avatar}"></div>
        <div class="user-txt">
            <div>{$ac_user.nickname}</div>
        </div>
    </a>
</div>
{block:script}
<script>

    /**
     * 插件类型获取
     */
    function getAddonsType(type)
    {
        type = type || $('#custom-tabs-three-tab').find('.nav-link.active').data('type')
        Util.ajax({ url:'{:url("/appcenter/getFilter")}?type='+type },'',
            function (data) {
                var html = '';
                if (data && data.category) {
                    if (data.category.length==0) {
                        $('#'+type+'-pane .category-panel').find('.content').html('');
                        $('#'+type+'-pane .category-panel').hide();
                    }
                    html = '<li class="active"><a href="#" data-value="">{:lang("All")}</a></li>';
                    $.each(data.category, function (idx, vo) {
                        html += '<li><a href="#" data-value="category_id='+vo.id+'">'+vo.name+'</a>';
                        if (vo.childlist.length>0) {
                            html += '<span class="show-down" title="{:lang('Unfold')}" data-toggle="dropdown" data-offset="-140,0"><i class="fas fa-caret-square-down"></i></span><div class="dropdown-menu dropdown-menu-lg-left">';
                            $.each(vo.childlist, function (k,v) {
                                html += '<a href="#" data-value="category_id='+v.id+'" class="dropdown-item px-3 ">'+v.name+'</a>';
                            });
                            html += '</div>';
                        }
                        html += '</li>';
                    });
                    $('#custom-tabs-three-tabContent .tab-pane.active .category-panel').find('.content').html(html);
                }
                if (data && data.color_attr) {
                    if (data.category.length==0) {
                        $('.color_attr').find('.content').html('');
                        $('.color_attr').hide();
                    }

                    html = '<li class="active"><a href="#" data-value="">{:lang("All")}</a></li>';
                    $.each(data.color_attr, function (idx, vo) {
                        html += '<li><a href="#" data-value="color_attr='+vo+'">'+vo+'</a>';
                    });
                    $('.color_attr').find('.content').html(html);
                }

                getAddonList(type);
            }
        );
    }

    /**
     * 获取插件列表
     */
    function getAddonList(type, href)
    {
        var data = [];
        type = (type || $('#custom-tabs-three-tab').find('.nav-link.active').data('type'));
        data.push('type='+type);
        $('#custom-tabs-three-tabContent .tab-pane.active .card-body li.active').each(function (idx, vo) {
            if ($(this).find('a.active').length>0 && $(this).find('a.active').data('value').length>0) {
                data.push($(this).find('a.active').data('value'));
            } else if ($(this).children('a').data('value').length>0) {
                data.push($(this).children('a').data('value'));
            }
        });
        if ($('#'+type+'-keyword').val()) {
            data.push('keyword='+$('#'+type+'-keyword').val());
        }

        // 分页
        if (href) {
            var obj = Util.getUrlParams(href || '');
            data.push('page='+(obj && obj.page ? obj.page : 1));
        }

        if (data.length>0) {
            data = data.join('&');
            Util.ajax({
                url:'{:url("/Appcenter/online")}',
                data: {param: data}
            }, '', function (data) {
                $('#'+type+'-pane .template-list').html(data.html);
                $('#'+type+'-pane .template-total').html(data.total);
                $('#'+type+'-pane .navigation').html(data.page);
                $('[data-toggle="tooltip"]').tooltip();
            });
        }
    }

    require(['jquery','bootstrap','layer','jquery-fileupload'], function ($,undefined,Layer) {
        // 类型切换
        $('#custom-tabs-three-tab').on('click', 'a', function (e) {
            e.preventDefault();
            getAddonsType($(this).data('type'));
        });

        // 筛选点击
        $('#custom-tabs-three-tabContent .card-body').on('click','.tabs-group a',function (e) {
            e.preventDefault();
            if ($(this).parent().hasClass('active')) return false;
            $(this).parents('.tabs-group').find('.active').removeClass('active');
            $(this).parents('li').addClass('active');
            if ($(this).parent().hasClass('dropdown-menu')) {
                $(this).addClass('active');
            }
            getAddonList('');
        });

        // 页面跳转
        $('.tab-pane .navigation').on('click','a',function (e) {
            e.preventDefault();
            getAddonList('', $(this).attr('href'));
        });

        // 安装
        $(document).on('click', '.btn-install', function (e) {
            e.preventDefault();
            var version = $(this).data('version');
            var obj = {name:$(this).data('name')};
            if (typeof version !=='undefined') {
                obj.version = version;
            }

            Util.ajax({
                url:'{:url("/Appcenter/install")}',
                data: obj
            }, '', function (data) {
                layer.msg("{:lang("Operation completed")}",{time: 1000},function () {
                    getAddonList('');
                });
                return false;
            },function (data) {
                layer.alert(data.msg);
                return false;
            });
        });

        // 更新
        $(document).on('click', '.btn-upgrade', function (e) {
            e.preventDefault();
            var version = $(this).data('version');
            var obj = {name:$(this).data('name')};
            if (typeof version !=='undefined') {
                obj.version = version;
            }

            Util.ajax({
                url:'{:url("/Appcenter/upgrade")}',
                data: obj
            }, '', function (data) {
                layer.msg("{:lang("Operation completed")}",{time: 1000},function () {
                    getAddonList('');
                });
                return false;
            },function (data) {
                layer.alert(data.msg);
                return false;
            });
        });

        // 卸载
        $(document).on('click', '.btn-uninstall', function (e) {
            var that = this;
            layer.confirm('{:lang("Are you sure to uninstall?")}', {
                btn: ['{:lang("Uninstall")}','{:lang("Cancel")}']
            }, function(){
                var obj = {
                    name: $(that).data('name'),
                    type: $(that).data('type'),
                    module: $(that).data('module')
                }
                Util.ajax({
                    url:'{:url("/Appcenter/uninstall")}',
                    data: obj
                }, '', function (data) {
                    layer.msg("{:lang('Operation completed')}",{time: 1000},function () {
                        getAddonList('');
                    });
                },function (data) {
                    layer.alert(data.msg);
                    return false;
                });
            }, function(){
            });
        });

        // 启用、禁用
        $(document).on('change', '.custom-control-input', function (e) {
            e.preventDefault();

            let value = $(this).val();
            value = value==1?-1:1;

            Util.ajax({
                url:'{:url("/Appcenter/enable")}',
                data: {value:value,type:$('#custom-tabs-three-tab').find('.nav-link.active').data('type'),name:$(this).data('name')}
            }, '', function (data) {
                layer.msg("{:lang("Operation completed")}",{time: 1000},function () {
                    getAddonList('');
                });
            },function (data) {
                layer.alert(data.msg);
                return false;
            });
        });

        getAddonsType('');
    })
</script>
{/block:script}